package leetcode.medium.removeduplicates;

import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import util.SolutionValidator;

public class SolutionTest {
    private static Solution solution;

    @BeforeClass
    public static void setup() {
        SolutionValidator.checkSolved(Solution.class);
        solution = new Solution();
    }

    @AfterClass
    public static void tearUp() {
        solution = null;
    }

    @Test
    public void test1() {
        int[] nums = {1, 1, 2, 2, 2, 3, 3};
        int res = solution.removeDuplicates(nums);
        Assert.assertEquals(6, res);
        Assert.assertArrayEquals(new int[] {1, 1, 2, 2, 3, 3, 3}, nums);
    }

    @Test
    public void test2() {
        int[] nums = {1, 2, 2, 2, 3, 3};
        int res = solution.removeDuplicates(nums);
        Assert.assertEquals(5, res);
        Assert.assertArrayEquals(new int[] {1, 2, 2, 3, 3, 3}, nums);
    }

    @Test
    public void test3() {
        int[] nums = {1, 1, 1, 2, 2, 3};
        int res = solution.removeDuplicates(nums);
        Assert.assertEquals(5, res);
        Assert.assertArrayEquals(new int[] {1, 1, 2, 2, 3, 3}, nums);
    }

    @Test
    public void test4() {
        int[] nums = {0, 0, 1, 1, 1, 1, 2, 3, 3};
        int res = solution.removeDuplicates(nums);
        Assert.assertEquals(7, res);
        Assert.assertArrayEquals(new int[] {0, 0, 1, 1, 2, 3, 3, 3, 3}, nums);
    }
}
